package com.txunda.zhuohired.aty.user.home;

import android.os.Bundle;
import android.support.annotation.IdRes;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.widget.RadioButton;
import android.widget.RadioGroup;

import com.flyco.tablayout.utils.FragmentChangeManager;
import com.lidroid.xutils.view.annotation.ViewInject;
import com.txunda.zhuohired.R;
import com.txunda.zhuohired.base.BaseAty;
import com.txunda.zhuohired.fgt.user.home.AllJobFgt;
import com.txunda.zhuohired.fgt.user.home.PartJobFgt;

import java.util.ArrayList;

/**
 * 创建人： Txd_Cjh
 * 创建时间： 2018/4/19 10:19
 * 功能描述：卓聘直招
 * 联系方式：jiahuanchen@126.com
 */

public class DirectActionAty extends BaseAty implements RadioGroup.OnCheckedChangeListener {
    @ViewInject(R.id.rg_direct_head)
    private RadioGroup rg_direct_head;
    /**
     * 兼职
     */
    @ViewInject(R.id.rb_direct_part)
    private RadioButton rb_direct_part;
    /**
     * 全职
     */
    @ViewInject(R.id.rb_direct_all)
    private RadioButton rb_direct_all;

    private FragmentChangeManager fcm;
    private ArrayList<Fragment> fragments;
    private int checkStatus = 0;
    private AllJobFgt allJobFgt;
    private PartJobFgt partJobFgt;
    private String icon = "";//图标ID

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        showStatusBar(R.id.fl_direct_head);
        rg_direct_head.setOnCheckedChangeListener(this);
        fcm = new FragmentChangeManager(getSupportFragmentManager(), R.id.fl_direct, fragments);
    }

    @Override
    protected int getLayoutResId() {
        return R.layout.aty_direct_action;
    }

    @Override
    protected void initialized() {
        fragments = new ArrayList<>();
        allJobFgt = new AllJobFgt();
        partJobFgt = new PartJobFgt();
        fragments.add(partJobFgt);
        fragments.add(allJobFgt);
        icon = getIntent().getStringExtra("icon");
    }

    @Override
    protected void requestData() {

    }

    @Override
    public void onCheckedChanged(RadioGroup radioGroup, @IdRes int i) {
        switch (i) {
            case R.id.rb_direct_part://兼职
                checkStatus = 0;
                fcm.setFragments(0);
                break;
            case R.id.rb_direct_all://全职
                checkStatus = 1;
                fcm.setFragments(1);
                break;
        }

    }

    @Override
    public void onResume() {
        super.onResume();
        switch (checkStatus) {
            case 0:
                rb_direct_part.setChecked(true);
                break;
            case 1:
                rb_direct_all.setChecked(true);
                break;
        }
    }

}
